package test;

import java.util.Random;

import lib.BipartiteMatching;
import lib.MaxBipartiteMatching;

public class TextMaxBipartiteMatching {
	static MaxBipartiteMatching app;
	public static void main(String[] args) {
		app = new MaxBipartiteMatching();
		app.maxMatch(new int[][] {
				{1, 4, 5},
				{4, 3, 5},
				{6, 4, 5}
		});
		
		System.out.println(app.lefts[0] + ":" + app.lefts[1] + ":" + app.lefts[2] + " should match 1:2:0");
		System.out.println(app.rights[0] + ":" + app.rights[1] + ":" + app.rights[2] + " should match 2:0:1");
		
		app = new MaxBipartiteMatching();
		app.maxMatch(new int[][] {
				{0, 5},
				{0, 6}
		});
		
		System.out.println(app.lefts[0] + ":" + app.lefts[1] + " should match 0:1");
		
		app = new MaxBipartiteMatching();
		app.maxMatch(new int[][] {
				{0, 0, 5},
				{0, 0, 4},
				{0, 0, 3}
		});
		
		System.out.println(app.lefts[0] + ":" + app.lefts[1] + ":" + app.lefts[2] + " should match 2:0:1");
		
		int SIZE = 450;
		int[][] vals = new int[SIZE][SIZE];
		Random rand = new Random(-23508945);
		for(int i = 0; i < vals.length; i++) {
			for(int j = i; j < vals.length; j++) {
				vals[i][j] = rand.nextInt(10000);
				vals[j][i] = rand.nextInt(10000);
			}
		}
		long a = System.currentTimeMillis();
		app = new MaxBipartiteMatching();
		app.maxMatch(vals);
		long b = System.currentTimeMillis();
		System.out.println(app.lefts[0] + ":" + app.lefts[1] + ":" + app.lefts[2] + ":" + app.lefts[3] + " should match 437:270:131:264");
		System.out.println(app.rights[12] + ":" + app.rights[26] + ":" + app.rights[58] + ":" + app.rights[20] + " should match 370:345:95:436");
		System.out.println("timeDif = " + (b - a) + " ms");
	}
}
